<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="认证类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="authType">
              <j-dict-select-tag type="radio" v-model="model.authType" dictCode="finance_logistics_ec_auth_type" placeholder="请选择认证类型" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contact">
              <a-input v-model="model.contact" placeholder="请输入联系人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="QQ" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qq">
              <a-input v-model="model.qq" placeholder="请输入QQ"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="email">
              <a-input v-model="model.email" placeholder="请输入邮箱"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="联系人电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactPhone">
              <a-input v-model="model.contactPhone" placeholder="请输入联系人电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="国家" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="country">
              <a-input v-model="model.country" placeholder="请输入国家"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="运营平台" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operationPlatform">
              <a-input v-model="model.operationPlatform" placeholder="请输入运营平台"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公司名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyName">
              <a-input v-model="model.companyName" placeholder="请输入公司名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公司注册编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyCode">
              <a-input v-model="model.companyCode" placeholder="请输入公司注册编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公司法人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyLegalPerson">
              <a-input v-model="model.companyLegalPerson" placeholder="请输入公司法人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公司注册日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyRegDate">
              <j-date placeholder="请选择公司注册日期" v-model="model.companyRegDate"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公司注册地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyRegAddress">
              <a-input v-model="model.companyRegAddress" placeholder="请输入公司注册地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公司办公地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyAddress">
              <a-input v-model="model.companyAddress" placeholder="请输入公司办公地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否授权签署" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="izAuthorizeSign">
              <a-input v-model="model.izAuthorizeSign" placeholder="请输入是否授权签署"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否同一人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="izSamePerson">
              <a-input v-model="model.izSamePerson" placeholder="请输入是否同一人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公司营业执照" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyIdPhoto">
              <a-input v-model="model.companyIdPhoto" placeholder="请输入公司营业执照"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="授权书" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="authorizationLetter">
              <a-input v-model="model.authorizationLetter" placeholder="请输入授权书"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="合同" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessContract">
              <a-input v-model="model.businessContract" placeholder="请输入合同"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="身份证照片人像面" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardImg1">
              <a-input v-model="model.idCardImg1" placeholder="请输入身份证照片人像面"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="身份证照片国徽面" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardImg2">
              <a-input v-model="model.idCardImg2" placeholder="请输入身份证照片国徽面"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="身份证照片2人像面" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardImg3">
              <a-input v-model="model.idCardImg3" placeholder="请输入身份证照片2人像面"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="身份证照片2国徽面" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardImg4">
              <a-input v-model="model.idCardImg4" placeholder="请输入身份证照片2国徽面"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="认证状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="authStatus">
              <a-input v-model="model.authStatus" placeholder="请输入认证状态"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'BaseSettlementOrgAuthForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
           authType: [
              { required: true, message: '请输入认证类型!'},
           ],
           authStatus: [
              { required: true, message: '请输入认证状态!'},
           ],
        },
        url: {
          add: "/finance/baseSettlementOrgAuth/add",
          edit: "/finance/baseSettlementOrgAuth/edit",
          queryById: "/finance/baseSettlementOrgAuth/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>